
**互联网使用与个体环保参与度***************************************************//
**创建于2021-05-04**************************************************************
cd "C:\Users\xiwan\Desktop"
use cgss2013_14.dta, clear

quietly {

        gen year=2013

		capture drop Female
		gen Female = a2-1
		label var Female "if female"

		recode a7a (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5) (else=.), gen(Education)
		label var Education "education level"

		recode a501 (1=0) (0=1) (else=.), gen(Religion)
		
		gen Age = 2013 - a3a
		
		gen Age2 = Age^2

		capture drop Urban
		recode s5a (5=0) (1 2 3 4=1)(else=.), gen(Urban)
		label var Urban "urban area"
		
		gen Inc = a8a if inrange(a8a,0,1000000)
		label var Inc "total income"
		capture drop Lninc
		gen Income = ln(Inc+1)

		recode a10 (3 4=0)(1=1) (else=.), gen(CPC)
		label var CPC "if CP member"
		
		recode a89c (1=1)(2/4=0)(else=.), gen(F_CPC)
		label var F_CPC "if father CP member"
		
		recode a90c (1=1)(2/4=0)(else=.), gen(M_CPC)
		label var M_CPC "if mather CP member"
		
		recode a89g (1 3 6=1)(2 4 5=0)(else=.), gen(F_Unit)
		label var F_Unit "Father's work unit"
		
	   gen Health = a15 if a15>0  //越大越健康

		recode a311 (1/2=1) (3=2) (4/5=3) (else=.), gen(S_Activity)
		recode a44 (1=1) (2=0) (else=.), gen(Vote)
        
		*fixed effect
		gen Prov = s41
		label var Prov "province"
		
		recode a43a (1/2=1) (3=2) (4=3) (5=4) (6=5) (7/10=6) (else        =.),gen(S_Class)
        label var S_Class "your social status"
				    		
        recode b1 (3=1)(1 2=0)(else=.), gen(Hstatus)
        recode b2 (3=1)(1 2=0)(else=.), gen(Vstatus)

        recode a89b (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5)        (else=.), gen(F_Edu)

        recode a90b (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5)        (else=.), gen(M_Edu)
        gen P_Education = round(max(F_Edu, M_Edu))

       gen P_CPC = 1 if F_CPC ==1 | M_CPC==1
       replace P_CPC = 0 if P_CPC==.

       recode b24 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Evaluate1) 
       recode b23 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Evaluate2)
       gen Evaluation = Evaluate1 + Evaluate2

       recode b2201 (3=2)(2=1)(1=0)(else=.), gen(Category1)
       recode b2202 (3=2)(2=1)(1=0)(else=.), gen(Discuss1)
       recode b2203 (3=2)(2=1)(1=0)(else=.), gen(Bag1)
       recode b2204 (3=2)(2=1)(1=0)(else=.), gen(Recycle1)
       recode b2205 (3=2)(2=1)(1=0)(else=.), gen(Donate1)
       recode b2206 (3=2)(2=1)(1=0)(else=.), gen(Attention1)
       recode b2207 (3=2)(2=1)(1=0)(else=.), gen(Promote1)
       recode b2208 (3=2)(2=1)(1=0)(else=.), gen(Participate1)
       recode b2209 (3=2)(2=1)(1=0)(else=.), gen(Forest1)
       recode b2210 (3=2)(2=1)(1=0)(else=.), gen(Solution1)
       gen EPB = Category1 + Discuss1 + Bag1 + Recycle1 + Donate1 + Attention1 + Promote1 + Participate1 + Forest1 + Solution1  

      gen DEPB = Category1 + Bag1 + Recycle1 
      gen PEAP =  Discuss1 + Donate1 + Attention1 + Promote1 +Participate1 + Solution1 
      gen Environment3 =Donate1 +Promote1 + Participate1 + Forest1 + Solution1  
    
	recode a285 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Internet)

      bysort s44: egen meanx=mean(Internet)  
      by s44: egen ctx = count(Internet)
      gen Internetc = (meanx*ctx-Internet)/(ctx-1)
      drop if Internetc < 0   

      recode a284 (1=0)(2 3 4 5=1)(else=.), gen(television)
      recode a283 (1=0)(2 3 4 5=1)(else=.), gen(broadcast)
      recode a282 (1=0)(2 3 4 5=1)(else=.), gen(magazine)
      recode a281 (1=0)(2 3 4 5=1)(else=.), gen(newspaper)

**测度环保知识：正确回答问题的个数或正确回答问题的个数占总问题的比例
     recode b2501 (2=1)(1 3=0)(else=.), gen(Env1)
     recode b2502 (1=1)(2 3=0)(else=.), gen(Env2)
     recode b2503 (2=1)(1 3=0)(else=.), gen(Env3)
     recode b2504 (1=1)(2 3=0)(else=.), gen(Env4)
     recode b2505 (2=1)(1 3=0)(else=.), gen(Env5)
     recode b2506 (1=1)(2 3=0)(else=.), gen(Env6)
     recode b2507 (2=1)(1 3=0)(else=.), gen(Env7)
     recode b2508 (1=1)(2 3=0)(else=.), gen(Env8)
     recode b2509 (2=1)(1 3=0)(else=.), gen(Env9)
     recode b2510 (1=1)(2 3=0)(else=.), gen(Env10)

     gen Knowleadge = Env1 + Env2 + Env3 + Env4 + Env5 + Env6 + Env7 + Env8 + Env9 + Env10 

**测度对当地环境污染问题的了解情况
     recode b21a01 (1=1)(2=0)(else=.), gen(Sense1)
     recode b21a02 (1=1)(2=0)(else=.), gen(Sense2)
     recode b21a03 (1=1)(2=0)(else=.), gen(Sense3)
     recode b21a04 (1=1)(2=0)(else=.), gen(Sense4)
     recode b21a05 (1=1)(2=0)(else=.), gen(Sense5)
     recode b21a06 (1=1)(2=0)(else=.), gen(Sense6)
     recode b21a07 (1=1)(2=0)(else=.), gen(Sense7)
     recode b21a08 (1=1)(2=0)(else=.), gen(Sense8)
     recode b21a09 (1=1)(2=0)(else=.), gen(Sense9)
     recode b21a10 (1=1)(2=0)(else=.), gen(Sense10)
     recode b21a11 (1=1)(2=0)(else=.), gen(Sense11)
     recode b21a12 (1=1)(2=0)(else=.), gen(Sense12)

     gen Sense = Sense1 + Sense2 + Sense3 + Sense4 + Sense5 + Sense6 + Sense7 + Sense8 + Sense9 + Sense10 + Sense11 + Sense12 
	
	 merge m:1 s41 using pollute.dta, gen(merge)   
     keep if merge==3   //与从中国环境统计年鉴中的数据污染数据合并， pollute为省级废水排放总量、二氧化硫排放总量、氮氧化物排放总量、烟（粉）尘排放总量、工业固体废物产生量5个指标（单位为万吨）
     gen Pollution = pollution 

     global yx EPB DEPB PEAP Internet Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Education

     foreach y of global yx {
     drop if `y'==.
     save sample.dta, replace
     }
	 
}
use sample.dta, clear

/*****************************************
实证结果
******************************************/
quietly {

/***************************************** 
Table 1. 
******************************************/
global yx1 EPB Internet Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Education
 
tabstat $yx1 Knowleadge Sense Evaluation, stat(N mean sd min max) format(%6.3f) save 
matrix s0 = r(StatTotal) 
putexcel set table1.xlsx, replace 
putexcel A1 = ("descriptive statistics") 
putexcel A2 = matrix(s0)
putexcel clear

/*****************************************
Table 2
******************************************/
global xlist2 Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution i.Prov

global xlist3 Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Education i.Prov

oprobit EPB Internet i.Prov, vce(robust) 
est store m11
oprobit EPB Internet $xlist2, vce(robust)    
est store m21
oprobit EPB Internet $xlist3, vce(robust)   
est store m31

reg EPB Internet i.Prov, vce(robust)   
est store m1
reg EPB Internet $xlist2, vce(robust)   
est store m2
reg EPB Internet $xlist3, vce(robust)    
est store m3

/*****************************************
Table 3
******************************************/
gen age =1 if Age>=17 & Age<= 30  //青年群体
replace age = 2 if Age>=31 & Age<=44   //
replace age = 3 if  Age>=45 & Age<=64  //中年群体
replace age = 4 if   Age>=65  //中年群体

reg EPB c.Internet##i.age $xlist3, vce(robust)  //年长一些互联网效应更为明显
est store mm1
oprobit EPB c.Internet##i.age $xlist3, vce(robust)  //年长一些互联网效应更为明显
est store mmm1

gen Rural = 1 - Urban
reg EPB c.Internet##i.Rural $xlist3, vce(robust)  //农村地区互联网效应更为明显
est store mm2
oprobit EPB c.Internet##i.Rural $xlist3, vce(robust)  //农村地区互联网效应更为明显
est store mmm2

sum Income, detail
gen lowincome = 1 if Income < 9.615872
replace lowincome = 0 if Income >=  9.615872

reg EPB c.Internet##i.lowincome $xlist3, vce(robust)  //收入越低互联网效应更为明显
est store mm3
oprobit EPB c.Internet##i.lowincome $xlist3, vce(robust)  //收入越低互联网效应更为明显
est store mmm3

/*****************************************
Table 4
******************************************/
eoprobit EPB $xlist3, endog(Internet = Internetc $xlist3)
est store miv1

ivreg2 EPB $xlist3 (Internet = Internetc), first
est store miv2

/*****************************************
Table 5
******************************************/

ivreg2 EPB Knowleadge $xlist3 (Internet = Internetc), first 
est store ma1
ivreg2 EPB Sense $xlist3 (Internet = Internetc), first  
est store mb1
ivreg2 EPB Knowleadge Sense $xlist3 (Internet = Internetc), first  
est store mc1
ivreg2 EPB Evaluation $xlist3 (Internet = Internetc), first  
est store md1

/*****************************************
Table 6
******************************************/
eoprobit DEPB $xlist3, endog(Internet = Internetc $xlist3)
est store xm1
eoprobit PEAP $xlist3, endog(Internet = Internetc $xlist3)
est store xm2
eoprobit EPB television broadcast newspaper $xlist3, endog(Internet = Internetc $xlist3)
est store xm3

ivreg2 DEPB $xlist3 (Internet = Internetc), first
est store xm11
ivreg2 PEAP $xlist3 (Internet = Internetc), first
est store xm21
ivreg2 EPB television broadcast newspaper $xlist3 (Internet = Internetc), first
est store xm31

/*****************************************
输出回归结果
******************************************/
esttab m11 m21 m31 m1 m2 m3 using Table2.rtf, pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace  //Table 2

esttab mmm1 mmm2 mmm3 mm1 mm2 mm3 using Table3.rtf, keep(2.age#c.Internet 3.age#c.Internet 4.age#c.Internet 1.Rural#c.Internet 1.lowincome#c.Internet ) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 3

esttab miv1 miv2 using Table4.rtf, keep(Internet Internetc) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace  //Table 4

esttab miv2 ma1 mb1 mc1 md1 using Table5.rtf, keep(Internet Knowleadge Sense Evaluation) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace  //Table 5

esttab xm1 xm2 xm3 xm11 xm21 xm31 using Table6.rtf, keep(Internet television broadcast newspaper) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace  //Table 6
}


***脚注⑥的回归结果
oprobit Knowleadge Internet $xlist3, vce(robust)
est store x1
oprobit Sense Internet $xlist3, vce(robust)
est store x2
oprobit Evaluation Internet $xlist3, vce(robust)
est store x3
esttab x1 x2 x3 using jiaozhu6.rtf, keep(Internet) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace  //脚注⑥





